import request from "@/utils/request";
import {serverIp} from "../../public/config.js";
const API_BASE_URL = `http://${serverIp}:8081/jdyfy`;

/**
 * 公示相关API请求
 */

/**
 * 根据项目编号集合获取公示信息集合
 * @param projects
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const getPublicitysByProjectNumbers  = (projects) =>{
    return request.post(`${API_BASE_URL}/getPublicitys`,projects).then(res => {
        return res;
    })
}

/**
 * 添加公示信息
 * @param form
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const addPublicity = (form) =>{
    return request.post(`${API_BASE_URL}/publicity/save`, form)
        .then(res => {
            return res;
        })
};

/**
 * 删除公示信息
 * @param publicityName
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const deletePublicityByName = (publicityName) =>{
    return request.delete(`${API_BASE_URL}/publicity/delete`, {data: publicityName})
        .then(res => {
            return res;
        })
};

/**
 * 添加公示澄清信息
 * @param form
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const addPublicityClarify = (form) =>{
    return request.post(`${API_BASE_URL}/publicityClarify/save`, form)
        .then(res => {
            return res;
        })
};

/**
 * 根据项目编号获取公示澄清信息
 * @param projectNumber
 * @returns
 */
export const getClarifyByProjectNumber = (projectNumber) =>{
    return request.get(`${API_BASE_URL}/publicity/clarifyByProjectNumber`, {params: {projectNumber}})
        .then(res => {
            return res.data;
        })
};